package com.cskaoyan.shopping.utils;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

import javax.servlet.http.HttpServletRequest;

/**
 * @author ycc
 * @date 2022/07/30 14:48:51
 */
public class UserInfoUtil {

    public static Long getUserId(HttpServletRequest request){
        String userInfo = request.getHeader("user_info");
        JSONObject object = JSON.parseObject(userInfo);
        if (object == null) {
            return null;
        }
        return Long.parseLong(object.get("uid").toString());
    }

    public static String UserIdStr(Long userId){
        return ""+userId;
    }
}
